package cn.lonecloud.action.user;

import java.io.IOException;
import java.util.Date;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.lonecloud.model.User;
import cn.lonecloud.service.UserService;
import cn.lonecloud.service.impl.UserServiceImpl;
import cn.lonecloud.util.ServletUtils;

/**
 * 保存注册信息
 *
 * @author lonecloud
 */
@WebServlet("/doRegister")
public class DoRegisterServlet extends HttpServlet {

	private UserService userService=new UserServiceImpl();
	/**
	 * 
	 */
	private static final long serialVersionUID = -3391351553325096380L;

	@Override
	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		String loginName=request.getParameter("loginName");
		String username = request.getParameter("username");
		String password = request.getParameter("password");
		String sex=request.getParameter("sex");
		User user=new User();
		user.setName(username);
		user.setLoginName(loginName);
		user.setPassword(password);
		user.setRegisterTime(new Date());
		user.setSex(sex);
		userService.save(user);
		ServletUtils.forwardUrl(request, response, "/");
	}
}
